<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
















  
  
  <link href="/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />







<link href="/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/blog/css/main.css?v=5.1.4" rel="stylesheet" type="text/css" />


  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png?v=5.1.4">


  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png?v=5.1.4">


  <link rel="mask-icon" href="/blog/images/logo.svg?v=5.1.4" color="#222">





  <meta name="keywords" content="Hexo, NexT" />










<meta property="og:type" content="website">
<meta property="og:title" content="smallmuou&#39;s blog">
<meta property="og:url" content="http://smallmuou.gitee.io/blog/page/11/index.html">
<meta property="og:site_name" content="smallmuou&#39;s blog">
<meta property="og:locale" content="zh-Hans">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="smallmuou&#39;s blog">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/blog/',
    scheme: 'Muse',
    version: '5.1.4',
    sidebar: {"position":"left","display":"post","offset":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="http://smallmuou.gitee.io/blog/page/11/"/>





  <title>smallmuou's blog</title>
  








</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left 
  page-home">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">smallmuou's blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"><a href="https://github.com/smallmuou">https://github.com/smallmuou</a></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/blog/categories/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/blog/about/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            
  <section id="posts" class="posts-expand">
    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/10/13/2016-10-13-apache2配置反向代理/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/10/13/2016-10-13-apache2配置反向代理/" itemprop="url">apache2配置反向代理</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-10-13T00:00:00+08:00">
                2016-10-13
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/后端/" itemprop="url" rel="index">
                    <span itemprop="name">后端</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>关于反向代理的概念，这里就不过多阐述，我们直接进入正题</p>
<h3 id="步骤1：安装"><a href="#步骤1：安装" class="headerlink" title="步骤1：安装"></a>步骤1：安装</h3><ul>
<li><p>Debain/Ubuntu</p>
<pre>
sudo apt-get install apache2
</pre>
</li>
<li><p>Centos/Rethat</p>
<pre>
sudo yum install apache2
</pre>

</li>
</ul>
<h3 id="步骤2：加载模块"><a href="#步骤2：加载模块" class="headerlink" title="步骤2：加载模块"></a>步骤2：加载模块</h3><pre>
a2enmod proxy proxy_balancer proxy_http
/etc/init.d/apache2 restart
</pre>

<h3 id="步骤3：配置"><a href="#步骤3：配置" class="headerlink" title="步骤3：配置"></a>步骤3：配置</h3><ul>
<li>新建虚拟主机文件<br>vim /etc/apache2/site-available/test    </li>
</ul>
<p>PS: test是例子，大家可以根据自己的服务定制</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">&lt;VirtualHost *:80&gt;</span><br><span class="line">	# 主机域名</span><br><span class="line">    ServerName smallmuou.xyz</span><br><span class="line">    # 管理员邮件</span><br><span class="line">    ServerAdmin smallmuou@gmail.com</span><br><span class="line">    # Off表示开启反向代理，On表示开启正向代理</span><br><span class="line">	ProxyRequests Off</span><br><span class="line">	ProxyMaxForwards 100</span><br><span class="line">	ProxyPreserveHost On</span><br><span class="line">	# 反向路径</span><br><span class="line">	ProxyPass / http://127.0.0.1:8081/</span><br><span class="line">	ProxyPassReverse / http://127.0.0.1:8081/</span><br><span class="line">	&lt;Proxy *&gt;</span><br><span class="line">		Order Deny,Allow</span><br><span class="line">		Allow from all</span><br><span class="line">	&lt;/Proxy&gt;</span><br><span class="line">&lt;/VirtualHost&gt;</span><br></pre></td></tr></table></figure>
<ul>
<li>加载对应配置</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">a2ensite test</span><br><span class="line">/etc/init.d/apache2 reload</span><br></pre></td></tr></table></figure>
<p>PS: test与上面新建的文件名必须一致，如果要卸载，则用<code>a2dissite test</code></p>
<h3 id="步骤4：测试"><a href="#步骤4：测试" class="headerlink" title="步骤4：测试"></a>步骤4：测试</h3><p><br>浏览器访问域名，如果返回8081的内容，则表示配置成功</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/08/19/2016-08-19-Linux下邮件系统的搭建/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/08/19/2016-08-19-Linux下邮件系统的搭建/" itemprop="url">Linux下邮件系统的搭建</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-08-19T00:00:00+08:00">
                2016-08-19
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/运维/" itemprop="url" rel="index">
                    <span itemprop="name">运维</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>前端时间尝试了下自己搭建邮件系统，遇到了很多难点，主要是不了解邮件系统，如果你和一样不了解邮件系统，你可以先看下我的另一篇文章《<a href="/技巧/2016/08/18/邮箱系统的新认识.html">邮箱系统的新认识</a>》，相信在看完后再去搭建就会很明确。那假如你已经了解了邮箱系统，于是你可以继续往下看。</p>
<h3 id="步骤1-申请域名及添加MX记录"><a href="#步骤1-申请域名及添加MX记录" class="headerlink" title="步骤1 - 申请域名及添加MX记录"></a>步骤1 - 申请域名及添加MX记录</h3><p>这里就不多说，可以去Google，这里贴下我的解析配置，我的域名是smallmuou.xyz</p>
<table>
<thead>
<tr>
<th>记录类型</th>
<th>主机记录</th>
<th>记录值</th>
<th>MX优先级</th>
</tr>
</thead>
<tbody>
<tr>
<td>A</td>
<td>mail</td>
<td>xxx.xxx.xxx.xxx</td>
<td></td>
</tr>
<tr>
<td>MX</td>
<td>@</td>
<td>mail.smallmuou.xyz</td>
<td>10</td>
</tr>
<tr>
<td>A</td>
<td>@</td>
<td>xxx.xxx.xxx.xxx</td>
</tr>
</tbody>
</table>
<h3 id="步骤2-修改FQDN为邮件域名"><a href="#步骤2-修改FQDN为邮件域名" class="headerlink" title="步骤2 - 修改FQDN为邮件域名"></a>步骤2 - 修改FQDN为邮件域名</h3><p>可以去Google，贴下我的结果</p>
<pre>
[root@mail ~]# hostname -f
mail.smallmuou.xyz
</pre>

<h3 id="步骤3-选择服务软件"><a href="#步骤3-选择服务软件" class="headerlink" title="步骤3 - 选择服务软件"></a>步骤3 - 选择服务软件</h3><p>这里需要SMTP和POP3/IMAP服务软件，别问我为何。</p>
<ul>
<li><p>针对SMTP，查了下有Sendmail、Postfix，其实很多系统已经预装了Sendmail，但考虑到最优性，这里选择Postfix；</p>
</li>
<li><p>针对POP3/IMAP服务，大家比较推荐的是Dovecot</p>
</li>
</ul>
<h3 id="步骤4-安装Postfix"><a href="#步骤4-安装Postfix" class="headerlink" title="步骤4 - 安装Postfix"></a>步骤4 - 安装Postfix</h3><p>请使用Linux系统自带安装工具安装，Debain的apt-get、Centos的yum</p>
<pre>
apt-get install postfix
或
yum install postfix
</pre>

<h3 id="步骤5-配置Postfix"><a href="#步骤5-配置Postfix" class="headerlink" title="步骤5 - 配置Postfix"></a>步骤5 - 配置Postfix</h3><pre>
vim /etc/postfix/main.cf


myhostname = mail.smallmuou.xyz
mydomain = smallmuou.xyz
myorigin = $mydomain
inet_interfaces = all
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
home_mailbox = Maildir/

</pre>

<h3 id="步骤6-启动Postfix"><a href="#步骤6-启动Postfix" class="headerlink" title="步骤6 - 启动Postfix"></a>步骤6 - 启动Postfix</h3><p>在启动前，可以先查看下25端口占用情况，如果端口被占用，将会导致无法启动</p>
<pre>
[root@mail ~]# lsof -i:25
COMMAND   PID USER   FD   TYPE    DEVICE SIZE/OFF NODE NAME
master  11093 root   12u  IPv4 430554452      0t0  TCP *:smtp (LISTEN)
</pre>
PS: 这里我已经启动了postfix，因此25端口是被占用


通过`service postfix start` 或`/etc/init.d/postfix start`启动postfix

### 步骤7 - 测试Postfix
搭建完服务必备的动作就是测试，这里可以通过telnet来测试

<pre>
telnet localhost 25
ehlo mail.smallmuou.xyz
mail from: root@smallmuou.xyz
rcpt to:root@smallmuou.xyz
data
subject:11212
test
</pre>
PS: <ctrl+d> 发送，可以通过`postqueue -p`查看发送队列，当然可以安装mailutils来简化发送流程

### 步骤8 - SMTP认证
<pre>
vim /usr/lib/sasl2/smtpd.conf
pwcheck_method: saslauthd
</pre>

<pre>
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_security_options = noanonymous
smtpd_banner = $myhostname ESMTP "SMTP Auth Required."
broken_sasl_auth_clients = yes
smtpd_recipient_restrictions = permit_mynetworks,permit_sasl_authenticated,reject_unauth_destination,reject_rbl_client
smtpd_sasl_path = private/auth
smtpd_sasl_type = dovecot
</pre>

<p>PS: 启动saslauthd和postfix</p>
<h3 id="步骤9-安装Dovecot"><a href="#步骤9-安装Dovecot" class="headerlink" title="步骤9 - 安装Dovecot"></a>步骤9 - 安装Dovecot</h3><pre>
yum install dovecot
或
apt-get install dovecot
</pre>

<h3 id="步骤10-配置Dovecot"><a href="#步骤10-配置Dovecot" class="headerlink" title="步骤10 - 配置Dovecot"></a>步骤10 - 配置Dovecot</h3><pre>
vim /etc/dovecot/dovecot.conf


protocols = imap pop3 lmtp
listen = *
mail_location = maildir:~/Maildir
</pre>

<h3 id="步骤11-启动Dovecot"><a href="#步骤11-启动Dovecot" class="headerlink" title="步骤11 - 启动Dovecot"></a>步骤11 - 启动Dovecot</h3><p>通过<code>service dovecot start</code> 或<code>/etc/init.d/dovecot start</code>启动dovecot</p>
<p>启动后查看下端口信息，POP3默认端口是110，IMAP默认端口143</p>
<h3 id="步骤12-测试Dovecot"><a href="#步骤12-测试Dovecot" class="headerlink" title="步骤12 - 测试Dovecot"></a>步骤12 - 测试Dovecot</h3><ul>
<li>检测POP3服务</li>
</ul>
<pre>
[root@mail ~]# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
+OK Dovecot ready.
</pre>
PS：quit退出

* 检测IMAP服务
<pre>
[root@mail ~]# telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
* OK [CAPABILITY IMAP4rev1 LITERAL+ SASL-IR LOGIN-REFERRALS ID ENABLE IDLE STARTTLS AUTH=PLAIN AUTH=LOGIN] Dovecot ready.
</pre>
PS：e logout退出

### 步骤13 - 新建用户

邮件用户对应的就是系统的用户，可以通过useradd添加用户

<pre>
useradd test
passwd test
</pre>

<h3 id="步骤14-客户端连接"><a href="#步骤14-客户端连接" class="headerlink" title="步骤14 - 客户端连接"></a>步骤14 - 客户端连接</h3><p>通过foxmail、outlook设置邮箱，其中认证部分需要用用户名+密码登录，<code>用户名不用带后缀</code>，否则会提示帐号密码错误</p>
<h3 id="步骤15-完成"><a href="#步骤15-完成" class="headerlink" title="步骤15 - 完成"></a>步骤15 - 完成</h3><p>以上是配置邮箱的所有步骤</p>
<h3 id="写在最后"><a href="#写在最后" class="headerlink" title="写在最后"></a>写在最后</h3><p><code>最最重要</code>：如果用户量、发送量、容量要求不大，可以使用第三方免费企业邮，如网易企业邮、腾讯企业邮，这样不用自己去维护. 上面只是邮件系统的简单版，还需要添加垃圾邮件机制、用户管理等.</p>
</ctrl+d>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/08/19/2016-08-19-域名解析的那些事/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/08/19/2016-08-19-域名解析的那些事/" itemprop="url">域名解析的那些事</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-08-19T00:00:00+08:00">
                2016-08-19
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/运维/" itemprop="url" rel="index">
                    <span itemprop="name">运维</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>域名是指向一个IP，这也许是每个人都知道，估计也是很多人唯一知道的。但其实域名的用法还有其他很多用户，如MX记录、CNAME等，这些都是非常重要的功能，因此大家有必要掌握各种域名解析方法。一条域名解析包含<code>记录类型</code>、<code>主机记录</code>、<code>记录值</code>、<code>TTL</code>等</p>
<h3 id="记录类型"><a href="#记录类型" class="headerlink" title="记录类型"></a>记录类型</h3><ul>
<li>A记录：将域名指向一个IPv4地址（例如：10.10.10.10），需要增加A记录</li>
<li>CNAME记录：如果将域名指向一个域名，实现与被指向域名相同的访问效果，需要增加CNAME记录</li>
<li>MX记录：建立电子邮箱服务，将指向邮件服务器地址，需要设置MX记录</li>
<li>NS记录：域名解析服务器记录，如果要将子域名指定某个域名服务器来解析，需要设置NS记录</li>
<li>TXT记录：可任意填写（可为空），通常用做SPF记录（反垃圾邮件）使用</li>
<li>AAAA记录：将主机名（或域名）指向一个IPv6地址（例如：ff03:0:0:0:0:0:0:c1），需要添加AAAA记录</li>
<li>SRV记录：记录了哪台计算机提供了哪个服务。格式为：服务的名字.协议的类型（例如：_example-server._tcp）</li>
<li>显性URL：将域名指向一个http（s)协议地址，访问域名时，自动跳转至目标地址（例如：将<a href="http://www.net.cn显性转发到www.hichina.com后，访问www.net.cn时，地址栏显示的地址为：www.hichina.com）。" target="_blank" rel="noopener">www.net.cn显性转发到www.hichina.com后，访问www.net.cn时，地址栏显示的地址为：www.hichina.com）。</a></li>
<li>隐性URL：与显性URL类似，但隐性转发会隐藏真实的目标地址（例如：将<a href="http://www.net.cn隐性转发到www.hichina.com后，访问www.net.cn时，地址栏显示的地址仍然为：www.net.cn）。" target="_blank" rel="noopener">www.net.cn隐性转发到www.hichina.com后，访问www.net.cn时，地址栏显示的地址仍然为：www.net.cn）。</a></li>
</ul>
<h3 id="主机记录"><a href="#主机记录" class="headerlink" title="主机记录"></a>主机记录</h3><ul>
<li>www ：将域名解析为<a href="http://www.example.com，填写www；" target="_blank" rel="noopener">www.example.com，填写www；</a></li>
<li>@ ：将域名解析为example.com（不带www），填写@或者不填写；</li>
<li>mail ：将域名解析为mail.example.com，通常用于解析邮箱服务器；</li>
<li>* ：泛解析，所有子域名均被解析到统一地址（除单独设置的子域名解析）；</li>
<li>二级域名 ：如：mail.example.com或abc.example.com，填写mail或abc；</li>
<li>手机网站 ：如：m.example.com，填写m。</li>
</ul>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/08/19/2016-08-19-如何查看Linux内存使用情况/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/08/19/2016-08-19-如何查看Linux内存使用情况/" itemprop="url">如何查看Linux内存使用情况</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-08-19T00:00:00+08:00">
                2016-08-19
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/SHELL/" itemprop="url" rel="index">
                    <span itemprop="name">SHELL</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>内存是计算机不可或缺的一部分，不论是Window还是Linux，内存占用过高，计算机就会慢下来，因此我们需要知道当前内存使用情况，从而更好地控制计算机，那么在Linux我们如何查看我们的内存？</p>
<h3 id="free命令"><a href="#free命令" class="headerlink" title="free命令"></a>free命令</h3><p>在Linux下，我们可以通过free查看内存情况，尝试下</p>
<p><pre><br>[root@git ~]# free<br>             total       used       free     shared    buffers     cached<br>Mem:      16027252   13337732    2689520     129840    1069464    8293852<br>-/+ buffers/cache:    3974416   12052836<br>Swap:      8085500          4    8085496<br></pre><br>PS: 通过上述Mem、total、used、free，于是我们就得出该计算机内存16G、已使用13.3G、剩余2.6G，可实际这里面有很多猫腻，buffers、cached呢？我只跑了gitlab，怎么会使用13G内存？</p>
<p>现在我们来详细地介绍这些含义，1、2表示第一二行</p>
<ul>
<li>total1：表示物理 内存总量</li>
<li>used1：表示总计分配给缓存（包含buffers 与cache ）使用的数量，但其中可能部分缓存并未实际使用</li>
<li>free1：未被分配的内存</li>
<li>shared1：共享内存，一般系统不会用到，这里也不讨论</li>
<li>buffers1： 系统分配但未被使用的buffers 数量（内存到磁盘的缓存）</li>
<li>cached1：系统分配但未被使用的cache 数量（cpu到内存的缓存）</li>
<li>used2：实际使用的buffers 与cache 总量，也是实际使用的内存总量</li>
<li><p>free2：未被 使用的buffers 与cache 和未被分配的内存之和，这就是系统当前实际可用内存</p>
</li>
<li><p>总内存 = used1 + free1 = used2 + free2</p>
</li>
<li>理论上总使用内存 = buffers1 + cached1 + used2</li>
<li>总剩余内存 =  buffers1 + cached1 + used2</li>
<li>实际使用内存 = used2</li>
</ul>
<p><code>需要理解buffers和cached都是可以使用的内存</code></p>
<h3 id="例子"><a href="#例子" class="headerlink" title="例子"></a>例子</h3><p>free、top输出的单位是kb，如果需要看到更直观的值，可以使用<code>free -h</code></p>
<p><pre><br>[root@git ~]# free -h<br>             total       used       free     shared    buffers     cached<br>Mem:           15G        12G       2.5G       126M       1.0G       7.9G<br>-/+ buffers/cache:       3.9G        11G<br>Swap:         7.7G         4K       7.7G<br></pre><br>PS: 总内存15G、已使用3.9G，剩余11G，现在我们不会傻傻地认为系统只有2.5G可用内存</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/08/18/2016-08-18-邮箱系统的新认识/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/08/18/2016-08-18-邮箱系统的新认识/" itemprop="url">邮箱系统的新认识</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-08-18T00:00:00+08:00">
                2016-08-18
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/运维/" itemprop="url" rel="index">
                    <span itemprop="name">运维</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>这段时间公司需要使用自己的域名来构建一个邮箱，于是想了解下邮箱系统，发现里面的水很深，本文将记录下这些新知识。</p>
<h3 id="邮箱系统组成（宏观）"><a href="#邮箱系统组成（宏观）" class="headerlink" title="邮箱系统组成（宏观）"></a>邮箱系统组成（宏观）</h3><pre>
 ------------------------                ------------------------
|         client         |              |         client         |
 ------------------------                ------------------------
    ↑               |                       |               ↑
    |               |                       |               |
    |               ↓                       ↓               |
 --------        --------                --------        --------
|        |      |        | -----------> |        |      |        | 
|POP/IMAP|      |  SMTP  |              |  SMTP  |      |POP/IMAP|
|        |      |        | <----------- |="" --------="" ↑="" ↓="" ------------------------="" mailbox="" <="" pre="">

<ul>
<li>client - 邮件客户端，包含本地客户端(foxmail、outlook、Mail等)和web客户端</li>
<li>POP/IMAP - 接收服务器，主要用于客户端读取存在store中的邮件</li>
<li>SMTP - 发送服务器，用于收发邮件及存储</li>
<li>mailbox - 存储邮件</li>
</ul>
<p>PS： 通过上图，大家应该比较容易理解为何客户端需要配置发送服务器及接收服务器</p>
<h3 id="邮箱系统组成（微观）"><a href="#邮箱系统组成（微观）" class="headerlink" title="邮箱系统组成（微观）"></a>邮箱系统组成（微观）</h3><p>从微观上讲，一个邮箱系统包含MTA、MDA、mailbox、POP/IMAP、MUA、MSA六个部分组成</p>
<pre>
 ------------------------                ------------------------
|  MUA             MSA   |              |  MSA             MUA   |
 ------------------------                ------------------------
    ↑                  |                  |                 ↑
    |                  |                  |                 |
    |                  ↓                  ↓                 |
 --------        --------                --------        --------
|        |      |        | -----------> |        |      |        | 
|POP/IMAP|      |MDA  MTA|              |MTA  MDA|      |POP/IMAP|
|        |      |        | <----------- |="" --------="" ↑="" ↓="" ------------------------="" mailbox="" <="" pre="">
* MTA - Mail Transfer Agent，向其他MTA发送邮件，接收或拒收其他MTA发来的邮件，属于SMTP
* MDA - Mail Delivery Agent，把本地MTA从远程发件人MTA接收到的邮件投递到用户的邮箱(mailbox)，属于SMTP
* mailbox - 存储用户的邮件
* POP/IMAP - 福州把mailbox的邮件传递给MUA，供用户查看
* MUA - Mail User Agent，即对应上方的client
* MSA - 用于客户端发邮件

### MX记录
在邮件系统中，有一个非常重要的东西，那就是MX记录，什么是MX记录？ 先提个问题，比如我要给12345678@qq.com 发送邮件，按照流程：客户端发送邮件到我们的SMTP，之后我们SMTP发到对方的SMTP，可是这里有个问题，我们的SMTP怎么知道往哪个SMTP呢？ SMTP仅仅只知道12345678@qq.com，其他一无所知.是谁完成这里面的红娘角色呢，当然就是MX记录.

MX即Mail Exchanger，指邮件交换记录，用于电子邮件系统发邮件时根据 收信人的地址后缀来定位邮件服务器，即每一种邮箱后缀都会对应至少一个MX记录，这条MX记录将包含STMP服务器地址及优先级，我们来测试几个常见邮箱后缀

<pre>
StarnetdeMacBook-Pro:Desktop starnet$ dig qq.com mx +short
30 mx1.qq.com.
20 mx2.qq.com.
10 mx3.qq.com.
You have new mail in /var/mail/starnet
StarnetdeMacBook-Pro:Desktop starnet$ dig 126.com mx +short
10 126mx03.mxmail.netease.com.
10 126mx02.mxmail.netease.com.
10 126mx01.mxmail.netease.com.
50 126mx00.mxmail.netease.com.
StarnetdeMacBook-Pro:Desktop starnet$ dig 163.com mx +short
10 163mx02.mxmail.netease.com.
10 163mx03.mxmail.netease.com.
10 163mx01.mxmail.netease.com.
50 163mx00.mxmail.netease.com.
StarnetdeMacBook-Pro:Desktop starnet$ dig gmail.com mx +short
20 alt2.gmail-smtp-in.l.google.com.
5 gmail-smtp-in.l.google.com.
30 alt3.gmail-smtp-in.l.google.com.
10 alt1.gmail-smtp-in.l.google.com.
40 alt4.gmail-smtp-in.l.google.com.
</pre>

<p>PS: 前一个数字表示优先级，后一个表示SMTP域名</p>
<h3 id="协议"><a href="#协议" class="headerlink" title="协议"></a>协议</h3><ul>
<li>SMTP协议 - MTA之间通信协议及MUA与MSA之间通信协议，一般位于TCP 25端口</li>
<li>POP3协议 - 邮箱查看协议</li>
<li>IMAP协议 - 邮箱查看协议，是POP3改进版，可以实现邮件同步，如在一台客户端删除，则其他客户端也会相应删除</li>
</ul>
<h3 id="常用服务端软件"><a href="#常用服务端软件" class="headerlink" title="常用服务端软件"></a>常用服务端软件</h3><ul>
<li>Sendmail - SMTP角色</li>
<li>Postfix - Sendmail改进版，主要解决Sendmail效率低问题</li>
<li>Dovecot - POP3/IMAP服务端</li>
</ul>
</-----------></pre></-----------></pre>
          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/08/12/2016-08-12-论linux下service的坑/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/08/12/2016-08-12-论linux下service的坑/" itemprop="url">论linux下service的坑</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-08-12T00:00:00+08:00">
                2016-08-12
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/SHELL/" itemprop="url" rel="index">
                    <span itemprop="name">SHELL</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>近日，通过service运行脚步来跑java程序，发现输出的中文都是?，而直接运行脚步又是正常的，感觉非常奇怪，于是通过<code>man service</code>查看</p>
<pre>
service(8)                                                          service(8)

NAME
       service - run a System V init script

SYNOPSIS
       service SCRIPT COMMAND [OPTIONS]

       service --status-all

       service --help | -h | --version

DESCRIPTION
       service runs a System V init script in as predictable environment as possible, removing most environment variables and with current working directory set to /.

       The  SCRIPT  parameter  specifies  a  System  V  init script, located in /etc/init.d/SCRIPT.  The supported values of COMMAND depend on the invoked script, service passes COMMAND and
       OPTIONS it to the init script unmodified.  All scripts should support at least the start and stop commands.  As a special case, if COMMAND is --full-restart, the script is run twice,
       first with the stop command, then with the start command.

       service --status-all runs all init scripts, in alphabetical order, with the status command.

FILES
       /etc/init.d
              The directory containing System V init scripts.

ENVIRONMENT
       LANG, TERM
              The only environment variables passed to the init scripts.

SEE ALSO
       chkconfig(8), ntsysv(8)
</pre>
其中提到`The only environment variables passed to the init scripts`，大致应该是说只传递LANG、TERM两个环境变量.猜测应该是环境变量的原因，果然通过export查看所有环境变量，并通过export引入所有变量；发现果然可以，于是逐一排查，发现是LANG没有传入，于是导入LANG，如下
<pre>
export LANG="zh_CN.UTF-8"
</pre>

<h3 id="为什么？"><a href="#为什么？" class="headerlink" title="为什么？"></a>为什么？</h3><p>可是为何需要引入LANG，通过spring boot查看<a href="https://github.com/spring-projects/spring-boot/blob/master/spring-boot/src/main/java/org/springframework/boot/context/FileEncodingApplicationListener.java" target="_blank" rel="noopener">启动代码</a>发现如下内容</p>
<pre>
/**
  ...
  * The System property {@code file.encoding} is normally set by the JVM in response to the
  * {@code LANG} or {@code LC_ALL} environment variables.
  ...
**/

 public class FileEncodingApplicationListener
        implements ApplicationListener<applicationenvironmentpreparedevent>, Ordered {
        ...
        String encoding = System.getProperty("file.encoding");
</applicationenvironmentpreparedevent></pre>

<p>PS：java通过file.encoding来读取编码，而file.encoding是通过LANG来决定，详情可以参考<a href="http://www.tuicool.com/articles/Ffiy2m" target="_blank" rel="noopener">这里</a></p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/08/09/2016-08-09-Swift调用ObjectiveC/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/08/09/2016-08-09-Swift调用ObjectiveC/" itemprop="url">Swift调用ObjectiveC</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-08-09T00:00:00+08:00">
                2016-08-09
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/IOS/" itemprop="url" rel="index">
                    <span itemprop="name">IOS</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>Swift中调用OC代码，并不是直接import头文件，然后开始调用，而是需要进行配置，方法也很简单，步骤如下：</p>
<ul>
<li><p>步骤一：添加Objective-C Bridging Header</p>
<pre>
TARGET -> Swift Compiler - Code Generation -> Objective-C Bridging Header 添加头文件
</pre>
</li>
<li><p>步骤二：调用代码</p>
<pre>
NSLog("你好".translatorToPinYinFirstAscii()); //此处不能使用OC的中括号写法
</pre>
</li>
</ul>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/07/08/2016-07-08-VPS加速(已验证有效)/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/07/08/2016-07-08-VPS加速(已验证有效)/" itemprop="url">VPS加速(已验证有效)</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-07-08T00:00:00+08:00">
                2016-07-08
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/工具/" itemprop="url" rel="index">
                    <span itemprop="name">工具</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>买了VPS也有一段时间了，主要作用还是翻墙，Google、youtube等等，发现特别是看youtube视频非常卡，于是想去看看有没有解决方法，当然搜到了不少tip，如ServerSpeeder、net-speeder、finalspeed、xsocks等，其中ServerSpeeder需要注册，稍显麻烦，而且目前不支持centos7.2系统；net-speeder属于比较简陋，因此也不考虑；最终尝试了finalspeed，速度果真上去，能够达到1MB以上，看youtube视频是杠杠的，下面我把配置流程记录下.</p>
<h2 id="服务端"><a href="#服务端" class="headerlink" title="服务端"></a>服务端</h2><ul>
<li>访问<a href="https://github.com/leesiyang/finalspeed，下载finalspeed_server.zip" target="_blank" rel="noopener">https://github.com/leesiyang/finalspeed，下载finalspeed_server.zip</a></li>
<li>unzip finalspeed_server.zip</li>
<li>chmod +x install_fs.sh </li>
<li>./install_fs.sh 2&gt;&amp;1 | tee install.log</li>
</ul>
<h2 id="客户端"><a href="#客户端" class="headerlink" title="客户端"></a>客户端</h2><ul>
<li>访问<a href="https://github.com/leesiyang/finalspeed，下载finalspeed_client1.2.zip" target="_blank" rel="noopener">https://github.com/leesiyang/finalspeed，下载finalspeed_client1.2.zip</a></li>
<li>sudo java -jar finalspeed_client.jar(一定用sudo，否则不支持tcp)</li>
<li>配置带宽、服务器地址、加速列表</li>
</ul>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/06/07/2016-06-07-理解Git的Rebase/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/06/07/2016-06-07-理解Git的Rebase/" itemprop="url">理解Git的Rebase</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-06-07T00:00:00+08:00">
                2016-06-07
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/版本管理/" itemprop="url" rel="index">
                    <span itemprop="name">版本管理</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>今天同事偶然问道<code>git rebase</code>的问题，于是想去了解下，可是看了好几篇文章都无法理解，后来理解了下rebase的词面意思，rebase可以理解为重新定义起点，可以结合下图理解：</p>
<p><img src="http://gitbook.liuhui998.com/assets/images/figure/rebase3.png" alt="image"></p>
<p>经过<code>git rebase</code>后，mywork分支的起点从C2切换到C4.</p>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
      

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="http://smallmuou.gitee.io/blog/blog/2016/06/06/2016-06-06-gitlab之repos位置迁移/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="smallmuou">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="smallmuou's blog">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">
                
                <a class="post-title-link" href="/blog/2016/06/06/2016-06-06-gitlab之repos位置迁移/" itemprop="url">gitlab之repos位置迁移</a></h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2016-06-06T00:00:00+08:00">
                2016-06-06
              </time>
            

            

            
          </span>

          
            <span class="post-category" >
            
              <span class="post-meta-divider">|</span>
            
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              
                <span class="post-meta-item-text">分类于</span>
              
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/blog/categories/版本管理/" itemprop="url" rel="index">
                    <span itemprop="name">版本管理</span>
                  </a>
                </span>

                
                
              
            </span>
          

          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        
          
            <p>前段时间gitlab服务出现503错误，查看了下日志，发现是gitlab数据所在的挂载点空间已经满了无法写入，于是想把数据迁移到另一个挂载点上，查了下gitlab仓库数据是位于<code>/var/opt/gitlab/git-data</code>下，于是最直接的做法就是把git-data拷贝到新挂载点下，然后建立一个软连接到<code>/var/opt/gitlab</code>下，而实际测试发现会有问题. 后来通过查看gitlab.rb配置文件，发现git_data_dir选项，于是通过把git_data_dir指向新挂载点，发现还是有问题，后来通过<a href="http://stackoverflow.com/questions/19902417/change-the-data-directory-gitlab-to-store-repos-elsewhere" target="_blank" rel="noopener">stackoverflow</a>找到了正确的方法，现记录于此:</p>
<h3 id="1-停止服务"><a href="#1-停止服务" class="headerlink" title="1. 停止服务"></a>1. 停止服务</h3><pre>
gitlab-ctl stop
</pre>

<h3 id="2-修改git-data-dir"><a href="#2-修改git-data-dir" class="headerlink" title="2. 修改git_data_dir"></a>2. 修改git_data_dir</h3><p>vim /etc/gitlab/gitlab.rb</p>
<pre>
git_data_dir "/mnt/new/git-data"
</pre>

<h3 id="3-拷贝"><a href="#3-拷贝" class="headerlink" title="3. 拷贝"></a>3. 拷贝</h3><pre>
rsync -av /var/opt/gitlab/git-data /mnt/new/git-data
</pre>
PS: 此处不能用cp，具体什么原因没有细查，有兴趣的童鞋可以去查查cp和rsync的区别

### 4. 生效配置
<pre>
gitlab-ctl reconfigure
</pre>

<h3 id="5-启动服务"><a href="#5-启动服务" class="headerlink" title="5. 启动服务"></a>5. 启动服务</h3><pre>
gitlab-ctl start
</pre>

          
        
      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      

      

      

      
      
        <div class="post-eof"></div>
      
    </footer>
  </div>
  
  
  
  </article>


    
  </section>

  
  <nav class="pagination">
    <a class="extend prev" rel="prev" href="/blog/page/10/"><i class="fa fa-angle-left"></i></a><a class="page-number" href="/blog/">1</a><span class="space">&hellip;</span><a class="page-number" href="/blog/page/10/">10</a><span class="page-number current">11</span><a class="page-number" href="/blog/page/12/">12</a><span class="space">&hellip;</span><a class="page-number" href="/blog/page/20/">20</a><a class="extend next" rel="next" href="/blog/page/12/"><i class="fa fa-angle-right"></i></a>
  </nav>



          </div>
          


          

        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      

      <section class="site-overview-wrap sidebar-panel sidebar-panel-active">
        <div class="site-overview">
          <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
            
              <p class="site-author-name" itemprop="name">smallmuou</p>
              <p class="site-description motion-element" itemprop="description"></p>
          </div>

          <nav class="site-state motion-element">

            
              <div class="site-state-item site-state-posts">
              
                <a href="/blog/archives/">
              
                  <span class="site-state-item-count">197</span>
                  <span class="site-state-item-name">日志</span>
                </a>
              </div>
            

            
              
              
              <div class="site-state-item site-state-categories">
                <a href="/blog/categories/index.html">
                  <span class="site-state-item-count">12</span>
                  <span class="site-state-item-name">分类</span>
                </a>
              </div>
            

            

          </nav>

          

          
            <div class="links-of-author motion-element">
                
                  <span class="links-of-author-item">
                    <a href="https://github.com/smallmuou" target="_blank" title="GitHub">
                      
                        <i class="fa fa-fw fa-globe"></i>GitHub</a>
                  </span>
                
            </div>
          

          
          

          
          

          

        </div>
      </section>

      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">smallmuou</span>

  
</div>

    <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>

    <span id="busuanzi_container_site_pv">总访问量<span id="busuanzi_value_site_pv"></span>次</span>
    <span class="post-meta-divider">|</span>



  <div class="powered-by">由 <a class="theme-link" target="_blank" href="https://hexo.io">Hexo</a> 强力驱动</div>



  <span class="post-meta-divider">|</span>



  <div class="theme-info">主题 &mdash; <a class="theme-link" target="_blank" href="https://github.com/iissnan/hexo-theme-next">NexT.Muse</a> v5.1.4</div>




        







        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  
    <script type="text/javascript" src="/blog/lib/jquery/index.js?v=2.1.3"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>
  

  
  
    <script type="text/javascript" src="/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>
  


  


  <script type="text/javascript" src="/blog/js/src/utils.js?v=5.1.4"></script>

  <script type="text/javascript" src="/blog/js/src/motion.js?v=5.1.4"></script>



  
  

  

  


  <script type="text/javascript" src="/blog/js/src/bootstrap.js?v=5.1.4"></script>



  


  




	





  





  












  





  

  

  

  
  

  

  

  

</body>
</html>
